package com.accp.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.accp.pojo.Goods;
import com.accp.service.GoodsService;
import com.accp.service.impl.GoodsServiceImpl;

@Controller
public class GoodsController {

	@Autowired
	GoodsService goodsService = new GoodsServiceImpl();

	@RequestMapping("getAllGoods")
	public String getAllGoods(HttpServletRequest request) {

		List<Goods> goodsList = goodsService.selectAllGoods();

		
		for (Goods goods : goodsList) {
			System.out.println(goods.getGoodsname());
		}
		
		request.setAttribute("goodsList", goodsList);
		
		return "Goods";
	}

	@RequestMapping("getGoodsToName")
	public String getGoodsToName(String goodsname,HttpServletRequest request) {

		
		
		System.out.println(goodsname+"!");
		List<Goods> goodsList = goodsService.selectGoodsToName(goodsname);

		
		
		
		//for (Goods goods : goodsList) {
		//	System.out.println(goods.getGoodsname());
		//}

		request.setAttribute("goodsList2", goodsList);
		
		return "Goods";
	}

}
